home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / mapmem.zip / README.TXT < prev   
Text File  |  1993-02-24  |  7KB  |  217 lines

  1. Build & Run Instructions:
  2. -------------------------
  3.  
  4. This sample is composed of two parts, the Win32 portion and the
  5. kernel device driver portion.  Each part can be found in their
  6. respective directories, WIN32 and DRIVER.
  7.  
  8. The Win32 portion contains a file, MEMTEST.C, which attempts to
  9. obtain a handle to MAPMEM.  The executable is built using the
  10. Windows NT SDK.  First update the environment and path by running
  11. <mstools>\setenv.bat.  Then change to the directory where you have
  12. the C source code and the makefile.  Type NMAKE to compile the Win32
  13. program, GETHNDL.EXE.
  14.  
  15. The kernel driver portion contains the driver source code, MAPMEM.C
  16. and a text file used to configure your registry so that the driver
  17. can be loaded.  The driver is built using the Windows NT DDK.
  18.  
  19. To build the driver:
  20.  
  21.  
  22.     1. Edit the MAPMEM\DRIVER\SOURCES file to make sure the INCLUDES
  23.        variable points to the proper (PRIVATE\NTOS\INC) path,
  24.  
  25.  
  26.     2. Assuming you have run <ddk_root>\setenv.bat, build the driver
  27.        by typing:
  28.  
  29.                build -cef
  30.  
  31.        (If there are any errors have a look at the build.log, build.err,
  32.         and build.wrn files to get an idea of what went wrong.)
  33.  
  34.  
  35.     3. Copy the newly built driver, OBJ\*\MAPMEM.SYS to the
  36.        <nt_root>\system\drivers directory, i.e.:
  37.  
  38.                copy obj\i386\mapmem.sys c:\winnt\system\drivers\
  39.  
  40.  
  41.     4. Update the registry by running regini.exe on ther mapmem.ini
  42.        file, i.e.:
  43.  
  44.                regini mapmem.ini
  45.  
  46.        This adds a MAPMEM driver node under the HKEY_LOCAL_MACHINE\
  47.        SYSTEM\CurrentControlSet\Services tree in the registry, and
  48.        also creates a MAPMEM symbolic link under ...\Control\
  49.        Session Manager\DOS Devices. You can verify this by starting
  50.        REGEDIT.EXE and looking the appropriate places.
  51.  
  52.  
  53.     5. Reboot.
  54.  
  55.     6. Type:
  56.  
  57.                net start mapmem
  58.  
  59.        ...and then execute MEMTEST.EXE.
  60.  
  61.  
  62. API Info:
  63. ---------
  64.  
  65. The ZwMapViewOfSection and ZwUnmapViewOfSection kernel-mode
  66. driver APIs provide a way to map and unmap a physical section
  67. of memory into the address space of a user mode process.
  68. These APIs were not prototyped or documented in the October
  69. 1992 release of the Windows NT Device Driver Kit.  However,
  70. they are included in the library (.LIB) files, and calls to
  71. these functions will be resolved by the linker at link time.
  72. A description and example of these APIs follow:
  73.  
  74.  
  75. NTSTATUS
  76. ZwMapViewOfSection(
  77.     IN HANDLE SectionHandle,
  78.     IN HANDLE ProcessHandle,
  79.     IN OUT PVOID *BaseAddress,
  80.     IN ULONG ZeroBits,
  81.     IN ULONG CommitSize,
  82.     IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
  83.     IN OUT PULONG ViewSize,
  84.     IN SECTION_INHERIT InheritDisposition,
  85.     IN ULONG AllocationType,
  86.     IN ULONG Protect
  87.     );
  88.  
  89. /*++
  90.  
  91. Routine Description:
  92.  
  93.     This function maps a view in the specified subject process to
  94.     the section object.
  95.  
  96. Arguments:
  97.  
  98.     SectionHandle - Supplies an open handle to a section object.
  99.  
  100.     ProcessHandle - Supplies an open handle to a process object.
  101.  
  102.     BaseAddress - Supplies a pointer to a variable that will
  103.          receive the base address of the view. If the initial
  104.          value of this argument is not null, then the view will
  105.          be allocated starting at the specified virtual
  106.          address rounded down to the next 64kb address
  107.          boundary. If the initial value of this argument is
  108.          null, then the operating system will determine
  109.          where to allocate the view using the information
  110.          specified by the ZeroBits argument value and the
  111.          section allocation attributes (i.e. based and
  112.          tiled).
  113.  
  114.     ZeroBits - Supplies the number of high order address bits that
  115.          must be zero in the base address of the section
  116.          view. The value of this argument must be less than
  117.          21 and is only used when the operating system
  118.          determines where to allocate the view (i.e. when
  119.          BaseAddress is null).
  120.  
  121.     CommitSize - Supplies the size of the initially committed
  122.          region of the view in bytes. This value is rounded up
  123.          to the next host page size boundary.
  124.  
  125.     SectionOffset - Supplies the offset from the beginning of the
  126.          section to the view in bytes. This value is
  127.          rounded down to the next host page size boundary.
  128.  
  129.     ViewSize - Supplies a pointer to a variable that will receive
  130.          the actual size in bytes of the view. If the value
  131.          of this argument is zero, then a view of the
  132.          section will be mapped starting at the specified
  133.          section offset and continuing to the end of the
  134.          section. Otherwise the initial value of this
  135.          argument specifies the size of the view in bytes
  136.          and is rounded up to the next host page size
  137.          boundary.
  138.  
  139.     InheritDisposition - Supplies a value that specifies how the
  140.          view is to be shared by a child process created
  141.          with a create process operation.
  142.  
  143.         InheritDisposition Values
  144.  
  145.  
  146.          ViewShare - Inherit view and share a single copy
  147.               of the committed pages with a child process
  148.               using the current protection value.
  149.  
  150.          ViewUnmap - Do not map the view into a child
  151.               process.
  152.  
  153.     AllocationType - Supplies the type of allocation.
  154.  
  155.          MEM_TOP_DOWN
  156.  
  157.     Protect - Supplies the protection desired for the region of
  158.          initially committed pages.
  159.  
  160.         Protect Values
  161.  
  162.  
  163.          PAGE_NOACCESS - No access to the committed region
  164.               of pages is allowed. An attempt to read,
  165.               write, or execute the committed region
  166.               results in an access violation (i.e. a GP
  167.               fault).
  168.  
  169.          PAGE_EXECUTE - Execute access to the committed
  170.               region of pages is allowed. An attempt to
  171.               read or write the committed region results in
  172.               an access violation.
  173.  
  174.          PAGE_READONLY - Read only and execute access to the
  175.               committed region of pages is allowed. An
  176.               attempt to write the committed region results
  177.               in an access violation.
  178.  
  179.          PAGE_READWRITE - Read, write, and execute access to
  180.               the region of committed pages is allowed. If
  181.               write access to the underlying section is
  182.               allowed, then a single copy of the pages are
  183.               shared. Otherwise the pages are shared read
  184.               only/copy on write.
  185.  
  186. Return Value:
  187.  
  188.     Returns the status
  189.  
  190. --*/
  191.  
  192.  
  193.  
  194. NTSTATUS
  195. ZwUnmapViewOfSection(
  196.     IN HANDLE ProcessHandle,
  197.     IN PVOID BaseAddress
  198.     );
  199.  
  200. /*++
  201.  
  202. Routine Description:
  203.  
  204.     This function unmaps a previously created view to a section.
  205.  
  206. Arguments:
  207.  
  208.     ProcessHandle - Supplies an open handle to a process object.
  209.  
  210.     BaseAddress - Supplies the base address of the view.
  211.  
  212. Return Value:
  213.  
  214.     Returns the status
  215.  
  216. --*/
  217.